﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProdTransSn" @search="()=>{getTableDataProdTransSn();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_ProdTransSn_Sn')">
            <el-input v-model="searchDataProdTransSn.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProdTransSn_ProductId')">
            <el-input v-model="searchDataProdTransSn.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_ProdTransSn_ProductCode')">
            <el-input v-model="searchDataProdTransSn.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_ProdTransSn_Wo')">
            <el-input v-model="searchDataProdTransSn.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurLineId_FormItem" prop="CurLineId" :label="$t('message.autotrans._Model_ProdTransSn_CurLineId')">
            <el-input v-model="searchDataProdTransSn.CurLineId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurLineCode_FormItem" prop="CurLineCode" :label="$t('message.autotrans._Model_ProdTransSn_CurLineCode')">
            <el-input v-model="searchDataProdTransSn.CurLineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurOpId_FormItem" prop="CurOpId" :label="$t('message.autotrans._Model_ProdTransSn_CurOpId')">
            <el-input v-model="searchDataProdTransSn.CurOpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurOpCode_FormItem" prop="CurOpCode" :label="$t('message.autotrans._Model_ProdTransSn_CurOpCode')">
            <el-input v-model="searchDataProdTransSn.CurOpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurRoutingId_FormItem" prop="CurRoutingId" :label="$t('message.autotrans._Model_ProdTransSn_CurRoutingId')">
            <el-input v-model="searchDataProdTransSn.CurRoutingId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CurRoutingCode_FormItem" prop="CurRoutingCode" :label="$t('message.autotrans._Model_ProdTransSn_CurRoutingCode')">
            <el-input v-model="searchDataProdTransSn.CurRoutingCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="InboundTime_FormItem" prop="InboundTime" :label="$t('message.autotrans._Model_ProdTransSn_InboundTime')">
            <el-date-picker v-model="searchDataProdTransSn.InboundTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutboundTime_FormItem" prop="OutboundTime" :label="$t('message.autotrans._Model_ProdTransSn_OutboundTime')">
            <el-date-picker v-model="searchDataProdTransSn.OutboundTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OnlineTime_FormItem" prop="OnlineTime" :label="$t('message.autotrans._Model_ProdTransSn_OnlineTime')">
            <el-date-picker v-model="searchDataProdTransSn.OnlineTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OfflineTime_FormItem" prop="OfflineTime" :label="$t('message.autotrans._Model_ProdTransSn_OfflineTime')">
            <el-date-picker v-model="searchDataProdTransSn.OfflineTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Stage_FormItem" prop="Stage" :label="$t('message.autotrans._Model_ProdTransSn_Stage')">
            <el-select v-model="searchDataProdTransSn.Stage" clearable>
               <el-option key="Inbound" value="Inbound" :label="$t('message.autotrans._Enum_SnStageEnum_Inbound')"></el-option>
               <el-option key="Outbound" value="Outbound" :label="$t('message.autotrans._Enum_SnStageEnum_Outbound')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_ProdTransSn_Status')">
            <el-select v-model="searchDataProdTransSn.Status" clearable>
               <el-option key="OK" value="OK" :label="$t('message.autotrans._Enum_SnStatusEnum_OK')"></el-option>
               <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_SnStatusEnum_NG')"></el-option>
               <el-option key="MandatoryOK" value="MandatoryOK" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryOK')"></el-option>
               <el-option key="MandatoryNG" value="MandatoryNG" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryNG')"></el-option>
               <el-option key="Scrap" value="Scrap" :label="$t('message.autotrans._Enum_SnStatusEnum_Scrap')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="IsCompelted_FormItem" prop="IsCompelted" :label="$t('message.autotrans._Model_ProdTransSn_IsCompelted')">
            <el-select v-model="searchDataProdTransSn.IsCompelted" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CustomerSn_FormItem" prop="CustomerSn" :label="$t('message.autotrans._Model_ProdTransSn_CustomerSn')">
            <el-input v-model="searchDataProdTransSn.CustomerSn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReworkFlag_FormItem" prop="ReworkFlag" :label="$t('message.autotrans._Model_ProdTransSn_ReworkFlag')">
            <el-select v-model="searchDataProdTransSn.ReworkFlag" clearable>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_ReworkFlagEnum_None')"></el-option>
               <el-option key="Wait" value="Wait" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Wait')"></el-option>
               <el-option key="Working" value="Working" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Working')"></el-option>
               <el-option key="Done" value="Done" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Done')"></el-option>
               <el-option key="DoneAndWaitToRelaunch" value="DoneAndWaitToRelaunch" :label="$t('message.autotrans._Enum_ReworkFlagEnum_DoneAndWaitToRelaunch')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReworkDoc_FormItem" prop="ReworkDoc" :label="$t('message.autotrans._Model_ProdTransSn_ReworkDoc')">
            <el-input v-model="searchDataProdTransSn.ReworkDoc" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReworkCount_FormItem" prop="ReworkCount" :label="$t('message.autotrans._Model_ProdTransSn_ReworkCount')">
            <el-input v-model="searchDataProdTransSn.ReworkCount" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="NgSteps_FormItem" prop="NgSteps" :label="$t('message.autotrans._Model_ProdTransSn_NgSteps')">
            <el-input v-model="searchDataProdTransSn.NgSteps" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="IsNeedRework_FormItem" prop="IsNeedRework" :label="$t('message.autotrans._Model_ProdTransSn_IsNeedRework')">
            <el-select v-model="searchDataProdTransSn.IsNeedRework" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProdTransSn_CreateTime')">
            <el-date-picker v-model="searchDataProdTransSn.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProdTransSn_UpdateTime')">
            <el-date-picker v-model="searchDataProdTransSn.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProdTransSn_CreateBy')">
            <el-input v-model="searchDataProdTransSn.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProdTransSn_UpdateBy')">
            <el-input v-model="searchDataProdTransSn.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/ProdTransSnExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProdTransSn" v-bind="tableDataProdTransSn">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdTransSn/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdTransSnIndex;true;Digitalmes.ProductionManagement.Controllers;ProdTransSn">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodtranssnApi } from '/@/api/productionmanagement/prodtranssn';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProdTransSn = reactive({
    
});

const searchDataProdTransSn = ref({
        Sn: '',
        ProductId: null,
        ProductCode: '',
        Wo: '',
        CurLineId: null,
        CurLineCode: '',
        CurOpId: null,
        CurOpCode: '',
        CurRoutingId: null,
        CurRoutingCode: '',
        InboundTime: undefined,
        OutboundTime: undefined,
        OnlineTime: undefined,
        OfflineTime: undefined,
        Stage: undefined,
        Status: undefined,
        IsCompelted: undefined,
        CustomerSn: '',
        ReworkFlag: undefined,
        ReworkDoc: '',
        ReworkCount: null,
        NgSteps: '',
        IsNeedRework: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProdTransSn = ref();
const tableDataProdTransSn = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'ProdTransSn_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品Id'),key: 'ProdTransSn_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品编码'),key: 'ProdTransSn_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'ProdTransSn_Wo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在产线Id'),key: 'ProdTransSn_CurLineId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在产线编号'),key: 'ProdTransSn_CurLineCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在工位'),key: 'ProdTransSn_CurOpId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在工位编号'),key: 'ProdTransSn_CurOpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在工艺路线'),key: 'ProdTransSn_CurRoutingId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所在工艺路线编号'),key: 'ProdTransSn_CurRoutingCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位进站时间'),key: 'ProdTransSn_InboundTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位出站时间'),key: 'ProdTransSn_OutboundTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品上线时间'),key: 'ProdTransSn_OnlineTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品下线时间'),key: 'ProdTransSn_OfflineTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工作阶段'),key: 'ProdTransSn_Stage',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page状态'),key: 'ProdTransSn_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page完工'),key: 'ProdTransSn_IsCompelted',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page客户SN'),key: 'ProdTransSn_CustomerSn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返工标识'),key: 'ProdTransSn_ReworkFlag',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返工单据'),key: 'ProdTransSn_ReworkDoc',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返修次数'),key: 'ProdTransSn_ReworkCount',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.PageNG步序号集合'),key: 'ProdTransSn_NgSteps',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page是否需要进行返工'),key: 'ProdTransSn_IsNeedRework',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProdTransSn_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProdTransSn_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProdTransSn_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProdTransSn_UpdateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminIsValid'),key: 'ProdTransSn_IsValid',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProdTransSn = () => {
    tableRefProdTransSn.value.doSearch(prodtranssnApi().search, searchDataProdTransSn.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProdTransSn)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProdTransSn)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProdTransSn)
};

// 删除
const onDelete = (row: any) => {
    prodtranssnApi().delete([row.ID]).then(() => { getTableDataProdTransSn()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProdTransSn.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      prodtranssnApi().delete(selectedids).then(() => { getTableDataProdTransSn()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProdTransSn.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProdTransSn)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProdTransSn)
};

const onExport = () => {
	const selected = tableRefProdTransSn.value.getSelectedRows();
	if (selected.length > 0) {
		prodtranssnApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		prodtranssnApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataProdTransSn();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

